package cn.hinglo.permission.common.config.config;

import cn.hinglo.baseservice.interceptors.BaseLimitationInterceptors;
import cn.hinglo.baseservice.interceptors.PermissionInterceptor;
import cn.hinglo.permission.common.config.interceptor.LoginInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;


/**
 * @author HingLo
 * @createTime: 2018/1/4
 * @description: 全局配置文件处理
 */
//@Configuration
public class WebConfig implements WebMvcConfigurer {

    @Autowired
    private PermissionInterceptor permissionInterceptor;

    /**
     * 全局拦截器处理配置
     *
     * @param interceptorRegistry 拦截器对象
     */
    @Override
    public void addInterceptors(InterceptorRegistry interceptorRegistry) {
        // 登录认证拦截器
        interceptorRegistry.addInterceptor(new LoginInterceptor()).addPathPatterns("/**").excludePathPatterns("/u/**");
        // 权限管理拦截器
        interceptorRegistry.addInterceptor(permissionInterceptor).addPathPatterns("/**").excludePathPatterns("/u/**");
        // 限流拦截器配置
        interceptorRegistry.addInterceptor(new BaseLimitationInterceptors()).addPathPatterns("/**");
    }
}
